// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class Chess extends cc.Component {

    @property([cc.SpriteFrame])
    frames:cc.SpriteFrame[] = [];

    _chessName:String;
    
    public get chessName() : String {
        return this._chessName;
    }
    
    // onLoad () {}

    start () {

    }

    // update (dt) {}

    init(chessName:String){
        this._chessName = chessName;
        this.node.getComponent(cc.Sprite).spriteFrame = this.frames.find(item => item.name == chessName);
        this.redHide();
    }
    /**
     * 隐藏
     */
    redHide() {
        this.node.children[0].active = false;
    }
    /**
     * 显示
     */
    redShow(){
        this.node.children[0].active = true;
    }
}
